package org.game.msgBuilder;

import org.bean.NoticeDTO;
import org.game.protobuf.s2c.S2CNoticeMsg;

import java.util.List;

/**
 * Created by fxf on 2018-1-9.
 */
public class NoticeMsgBuilder {

    public static S2CNoticeMsg.GetBillBoardNotice getBillBoardNoticeListMsg(List<NoticeDTO> noticeList){
        S2CNoticeMsg.GetBillBoardNotice.Builder builder = S2CNoticeMsg.GetBillBoardNotice.newBuilder();
        noticeList.forEach(notice -> builder.addBillBoardNotice(buildBillBoardNoticeMsg(notice)));
        return builder.build();
    }

    public static S2CNoticeMsg.BillBoardNotice buildBillBoardNoticeMsg(NoticeDTO notice){
        S2CNoticeMsg.BillBoardNotice.Builder builder = S2CNoticeMsg.BillBoardNotice.newBuilder();
        builder.setIndex(notice.getIdx())
                .setTag(notice.getTag())
                .setType(notice.getType())
                .setTitle(notice.getTitle())
                .setContent(notice.getContent())
                .setContextImg(notice.getContextImg())
                .setParam(notice.getParam())
                ;
        return builder.build();
    }

    public static S2CNoticeMsg.MarqueeNotice getMarqueeNoticeMsg(NoticeDTO notice){
        S2CNoticeMsg.MarqueeNotice.Builder builder = S2CNoticeMsg.MarqueeNotice.newBuilder();
        builder.setContent(notice.getContent());
        return builder.build();
    }
}
